package com.kyin.demo1;

public class MyDemo02 {


    //变量
    private String content;

    private String getContent() {
        return content;

    }

    public void setContent(String content) {
        this.content = content;
    }


    public static void main(String[] args) {
        MyDemo02 demo = new MyDemo02();

        for (int i = 0; i < 5; i++) {
            new Thread(() -> {
                synchronized (MyDemo02.class) {
                    demo.setContent(Thread.currentThread().getName() + "的数据");
                    System.out.println("------------------------");
                    System.out.println(Thread.currentThread().getName() + "--->" + demo.getContent());
                }
            }, "线程" + i).start();
        }
    }
}
